package com.pantech.app.call_log_enabler;

import android.content.SharedPreferences;
import android.content.Context;

public class UserSharedPreference {
	
	public static final String pref_CALLLOG_ONGOING = "sip_IsCallLog_ongoing";
    public static final String pref_UDP_CHECKED = "sip_IsUDP_checked";
    public static final String pref_DDMS_CHECKED = "sip_IsDDMS_checked";
    public static final String pref_PCAP_CHECKED = "sip_IsPCAP_checked";
    public static final String pref_RADIO_CHECKED = "sip_IsRADIO_checked";
    public static final String pref_REMOVE_BUFFER_CHECKED = "sip_IsRemoveBuffer_checked";
    public static final String pref_USE_APPLOG_IN_USERMODE = "sip_IsUseApplogInUsermode";
    public static final String pref_USE_GPS_CHECKED = "sip_IsUse_GPS_checked";
    public static final String pref_USE_NETWORK_LOCATION_CHECKED = "sip_IsUse_Network_Location_checked";
    public static final String pref_LOCATION_REFRESHING_TIME = "sip_Location_Refreshing_Time";
    public static final String pref_IS_BUSYBOX_CHECKED = "sip_IsBUSYBOX_checked";
    public static final String pref_IS_BUSYBOX_EXIST = "sip_IsBUSYBOX_exist";
    public static final String pref_IS_FIELDTEST_MODE = "sip_IsFieldtest_mode";
	
	public static SharedPreferences mPrefs = null;
	
	public UserSharedPreference(Context context) {
		mPrefs =  context.getSharedPreferences("LogAppPerference", context.MODE_WORLD_WRITEABLE);
	}
	
	public boolean getIsCallLog_ongoing() {
		return mPrefs.getBoolean(pref_CALLLOG_ONGOING, getDefaultBoolean_pref(pref_CALLLOG_ONGOING));
	}
	
	public boolean getBoolean_pref(String pref_string)
    {
    	return mPrefs.getBoolean(pref_string, getDefaultBoolean_pref(pref_string));
    }
    
    public void setBoolean_pref(String pref_string, boolean _value)
    {
    	SharedPreferences.Editor ed = mPrefs.edit();
        ed.putBoolean(pref_string, _value);
        ed.commit();
    }
    
    public boolean getDefaultBoolean_pref(String pref_string) {
		boolean default_boolean = false;

    	if(pref_string.equals(pref_DDMS_CHECKED)) {
    		default_boolean = true;
    	}else if(pref_string.equals(pref_PCAP_CHECKED)) {
    		default_boolean = true;
    	}else if(pref_string.equals(pref_REMOVE_BUFFER_CHECKED)) {
    		default_boolean = true;
    	}else if(pref_string.equals(pref_RADIO_CHECKED)){
    		default_boolean = true;
    	}
    	return default_boolean;
    }
    
    public void setDefault_pref() {
    	setBoolean_pref(pref_CALLLOG_ONGOING, getDefaultBoolean_pref(pref_CALLLOG_ONGOING));
    	setBoolean_pref(pref_UDP_CHECKED, getDefaultBoolean_pref(pref_UDP_CHECKED));
    	setBoolean_pref(pref_DDMS_CHECKED, getDefaultBoolean_pref(pref_DDMS_CHECKED));
    	setBoolean_pref(pref_PCAP_CHECKED, getDefaultBoolean_pref(pref_PCAP_CHECKED));
    	setBoolean_pref(pref_RADIO_CHECKED, getDefaultBoolean_pref(pref_RADIO_CHECKED));
    	setBoolean_pref(pref_REMOVE_BUFFER_CHECKED, getDefaultBoolean_pref(pref_REMOVE_BUFFER_CHECKED));
    	setBoolean_pref(pref_USE_APPLOG_IN_USERMODE, getDefaultBoolean_pref(pref_USE_APPLOG_IN_USERMODE));
    	setBoolean_pref(pref_USE_GPS_CHECKED, getDefaultBoolean_pref(pref_USE_GPS_CHECKED));
    	setBoolean_pref(pref_USE_NETWORK_LOCATION_CHECKED, getDefaultBoolean_pref(pref_USE_NETWORK_LOCATION_CHECKED));
    	setInt_pref(pref_LOCATION_REFRESHING_TIME, getDefaultInt_pref(pref_LOCATION_REFRESHING_TIME));
    	setBoolean_pref(pref_IS_BUSYBOX_CHECKED, getDefaultBoolean_pref(pref_IS_BUSYBOX_CHECKED));
    	setBoolean_pref(pref_IS_BUSYBOX_EXIST, getDefaultBoolean_pref(pref_IS_BUSYBOX_EXIST));
    	setBoolean_pref(pref_IS_FIELDTEST_MODE, getDefaultBoolean_pref(pref_IS_FIELDTEST_MODE));
    }
    
    public int getInt_pref(String pref_string)
    {
    	return mPrefs.getInt(pref_string, getDefaultInt_pref(pref_string));
    }
    
    public void setInt_pref(String pref_string, int _value)
    {
    	SharedPreferences.Editor ed = mPrefs.edit();
        ed.putInt(pref_string, _value);
        ed.commit();
    }
    
    public int getDefaultInt_pref(String pref_string) {
		int default_int = 0;

    	return default_int;
    }

}
